package com.zkdcloud.repository;

import com.zkdcloud.domain.Admin;
import org.jfaster.mango.annotation.DB;
import org.jfaster.mango.annotation.SQL;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 管理员repositry
 *
 * @author zk123
 * @version 2018/4/29
 */
@DB(table = "admin")
@Repository
public interface AdminDao {

    String column = " id,business_id,user_name,real_name,identity_num,password,gender,email,phone,status,create_time ";
    /**
     * 根据 用户名和密码查找用户
     *
     * @param username username
     * @param password password
     * @return number
     */
    @SQL("select " + column + " from admin where user_name = :1 and password = :2")
    List<Admin> findByUserNameAndPassword(String username, String password);

    /**
     * 添加admin
     *
     * @param admin admin
     */
    @SQL("insert into admin ("+column+") values(:id,:businessId,:userName,:realName," +
            ":identityNum,:password,:gender,:email,:phone,:status,:createTime)")
    Long addAdmin(Admin admin);

    /**
     * 根据用户名获取admin
     *
     * @param username username
     * @return List<Admin></>
     */
    @SQL("select " + column + " from admin where user_name = :1")
    List<Admin> findByUsername(String username);
}
